/*
 * @Author: szx
 * @Date: 2022-05-25 14:42:23
 * @LastEditTime: 2022-05-25 14:54:58
 * @Description:
 * @FilePath: \leetcode\面试题\10\01\01.js
 */
/**
 * @param {number[]} A
 * @param {number} m
 * @param {number[]} B
 * @param {number} n
 * @return {void} Do not return anything, modify A in-place instead.
 */
var merge = function (A, m, B, n) {
    let a,
        b,
        c = m + n - 1;
    m--;
    n--;
    while (c >= 0) {
        a = m < 0 ? -Infinity : A[m];
        b = n < 0 ? -Infinity : B[n];
        if (a < b) {
            A[c] = b;
            n--;
        } else {
            A[c] = a;
            m--;
        }
        c--;
    }
    return A;
};

var merge = function (A, m, B, n) {
    let a,
        b,
        c = m + n - 1;
    m--;
    n--;
    while (n >= 0) {
        a = m < 0 ? -Infinity : A[m];
        b = n < 0 ? -Infinity : B[n];
        if (a < b) {
            A[c] = b;
            n--;
        } else {
            A[c] = a;
            m--;
        }
        c--;
    }
    return A;
};
